<template>
  <div class="dataStatistics">
    <div class="tistics">
      <div id="main" class="reportForm" />
      <div class="app-container" />
    </div>
  </div>
</template>

<script>
import * as echarts from 'echarts'
import { getreportForm } from '@/api/reportForm'
export default {
  data() {
    return {
      charts: '',
      opinionData: {
        type: 'category',
        boundaryGap: false,
        data: []
      }
    }
  },

  created() {

  },
  // 调用
  mounted() {
    // this.$nextTick(function() {
    //   this.drawLine('main')
    // })
    this.reportForm()
  },
  methods: {
    // 请求
    async reportForm() {
      const res = await getreportForm()
      // console.log(res)
      res.title = { text: '用户来源' }
      res.tooltip = {
        trigger: 'axis',
        axisPointer: {
          type: 'cross',
          label: {
            backgroundColor: '#E9EEF3'
          }
        }
      }
      res.grid = {
        left: '3%',
        right: '4%',
        bottom: '3%',
        containLabel: true
      }
      this.opinionData.data.push(...res.xAxis[0].data)
      res.xAxis = [this.opinionData]
      console.log(res)
      this.charts = echarts.init(document.getElementById('main'))
      this.charts.setOption(res)
    }
  }
}
</script>

<style scoped lang='scss'>
.tistics {
  margin-left: 40px;
  margin-right: 40px;
  background-color: #fff !important;
  border-radius: 6PX;
  .reportForm {
    margin: 0 auto;
    width: 888px;
    height: 500px;
  }
}
</style>
